package servlet;

import dao.BusinessDao;
import dao.impl.BusinessDaoImpl;
import pojo.Business;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/businessServlet.do")
public class businessServlet extends HttpServlet {
    private static BusinessDao businessDao= new BusinessDaoImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String canteen = req.getParameter("canteen");
        System.out.println("canteen_no:"+canteen);
        List<Business> businessList= businessDao.findCanteenBus(canteen);
        for (Business bus :
                businessList) {
            System.out.println(bus.toString());
        }
        req.setAttribute("businessList",businessList);
        req.getRequestDispatcher("business_View.jsp").forward(req,resp);
    }
}
